package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: InviteLinkServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-14
 * @Version: 1.0
 * Table: pear_invite_link
 * Comment:
 * 邀请链接表
 */
@Service
public class InviteLinkServiceImpl extends InviteLinkServiceCustomImpl implements InviteLinkService {

    static {
        beanClassNameMap.put("invite_link", "inviteLinkServiceImpl");
        listMethodNameMap.put("invite_link", "listInviteLink");
        listMethodParameterClassNameMap.put("invite_link", "InviteLinkQueryRequest");
        updateMethodNameMap.put("invite_link", "updateInviteLink");
        updateMethodParameterClassNameMap.put("invite_link", "InviteLinkUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addInviteLink(InviteLinkAddRequest request) throws Exception {
        super.fixRequest("invite_link", "add", request);
        return super.addInviteLink(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateInviteLink(InviteLinkUpdateRequest request) throws Exception {
        InviteLink record = null;
        record = inviteLinkMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("invite_link", "update", request, record);
        return super.updateInviteLink(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteInviteLink(InviteLinkDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<InviteLink> list = null;
            InviteLinkExample example = new InviteLinkExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = inviteLinkMapper.selectByExample(example);
            fixRequest("invite_link", "delete", request, list);
        } else {
            fixRequest("invite_link", "delete", request);
        }
        return super.deleteInviteLink(request);
    }

    @Override
    public InviteLinkQueryResponse queryInviteLink(InviteLinkQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        InviteLinkQueryResponse result = super.queryInviteLink(request);
        checkResult("invite_link", "query", request, result);
        return result;
    }

    @Override
    public List<InviteLinkQueryResponse> listInviteLink(InviteLinkQueryRequest request) throws Exception {
        List<InviteLinkQueryResponse> list = super.listInviteLink(request);
        checkResult("invite_link", "list", request, list);
        return list;
    }

    @Override
    public Integer countInviteLink(InviteLinkQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("invite_link", "count", request);
        return super.countInviteLink(request);
    }

    @Override
    public BaseStatResponse statInviteLink(InviteLinkQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("invite_link", "stat", request);
        return super.statInviteLink(request);
    }

}
